﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Xna_Shootr
{
    abstract class Bullet : GameObject, IDrawable, IMoveable
    {
        public static List<Bullet> ActivatedBullets = new List<Bullet>();
        protected bool alive = false;

        public Bullet(Texture2D sprite)
            : base(sprite)
        {
            ActivatedBullets.Add(this);
        }

        public bool Alive 
        { 
            get { return alive; }
            set { alive = value; }
        }        

        #region IDrawable Members

        abstract public void Draw(SpriteBatch spriteBatch);        

        #endregion

        #region IMoveable Members

        virtual public void Push(Vector2 acceleration)
        {
            this.acceleration = acceleration;
        }

        virtual public void Update(GameTime elapsedTime)
        {
            if (alive)
            {
                position += velocity;
            }
        }

        virtual public bool OutOfBoundCheck(Rectangle rect)
        {
            if (!rect.Contains((int)position.X, (int)position.Y))
            {
                alive = false;
                return true;
            }
            else
            {
                return false;
            }
        }

        #endregion
    }
}
